﻿// -----------------------------------------------------------------------
// <copyright file="StoredProcedureNoResult.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Dhgms.TplHelper.Controller.Task.Sql
{
    using System;
    using System.Collections.Generic;
    using System.Data.Common;
    using System.Linq;
    using System.Text;

    using Dhgms.DataManager.Model.Helper.Database;
    using Dhgms.TplHelper.Model.Info.TaskResult;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public abstract class StoredProcedureNoResult<TDatabaseHelperClass, TParameterClass> :
        Base<SingleResultInteger32, TDatabaseHelperClass, TParameterClass>
        where TDatabaseHelperClass : DatabaseHelperBase<TParameterClass>, new()
        where TParameterClass : DbParameter
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NonQuery{TDatabaseHelperClass,TParameterClass}"/> class. 
        /// </summary>
        /// <param name="taskName">
        /// The name of the task
        /// </param>
        /// <param name="connectionString">
        /// Database Connection String
        /// </param>
        protected StoredProcedureNoResult(string taskName, string connectionString)
            : base(taskName, connectionString)
        {
        }

        #endregion

        #region Methods

        /// <summary>
        /// The OnProcess event for doing the donkey work
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        protected override void OnProcess(SingleResultInteger32 result)
        {
            this.DbHelper.ExecuteNonQueryStoredProcedure(this.ConnectionString, this.GetSql(), this.GetParameters(), false);
        }

        #endregion
    }
}
